package com.itmayiedu;

import com.itmayiedu.annotation.AddAnnotation;

import java.lang.reflect.Method;
import java.util.Arrays;

/**
 * @author by Mr. Li 2020/9/7 22:46
 */
public class Main {
    public static void main(String[] args) throws ClassNotFoundException {
        /**
         * 测试获取该注解修饰的类
         */
        Class<?> clazz = Class.forName("com.itmayiedu.annotation.User");

        // 获取所有的方法
        Method[] declaredMethods = clazz.getDeclaredMethods();
        for (Method declaredMethod : declaredMethods) {
            // 获取该类的所有方法，是否存在该注解
            AddAnnotation declaredAnnotation = declaredMethod.getDeclaredAnnotation(AddAnnotation.class);
            if (declaredAnnotation != null) {
                System.out.println("userId :  " + declaredAnnotation.userId());
                System.out.println("userName :  " + declaredAnnotation.userName());
                System.out.println("arrays :  " + Arrays.toString(declaredAnnotation.arrays()));
            }
        }
    }
}
